
<cfset BASE = CreateObject("component", "cfc.base") />

<cfparam default="none" name="url.type" />
<cfparam default="none" name="url.api" />

<cfoutput>



<!---                                                                                                                --->  



	<!--- API that returns active providers from the providers table.  Function: funcQryActiveProviders--->
	<cfif url.api eq "providers" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#">
            <cfcase value="GET" >
                #SerializeJSON(CreateObject("component", "cfc.queries").funcQryActiveProviders())#
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that returns active providers from the providers table.  Function: funcQryActiveProviders--->
    
    
    
    <!--- API that returns active providers from the providers table.  Function: funcQryProvidersByID--->
	<cfif url.api eq "get_provider" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#">
            <cfcase value="GET" >
                #SerializeJSON(CreateObject("component", "cfc.queries").funcQryProvidersByID(url.id), 'true')#
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that returns active providers from the providers table.  Function: funcQryProvidersByID--->
    
    
    
    
    <!--- API that returns all providers from the providers table.  Function: funcQryAllProviders--->
	<cfif url.api eq "all_providers" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#"> 
            <cfcase value="GET" >
                #SerializeJSON(CreateObject("component", "cfc.queries").funcQryAllProviders())#
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that returns all providers from the providers table.  Function: funcQryAllProviders--->

  
    
    
    <!--- API that returns all elders meals from db for today.  Function: funcQryGetEldersMeals--->
	<cfif url.api eq "get_elders_meals" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#"> 
            <cfcase value="GET" >
                #SerializeJSON(CreateObject("component", "cfc.queries").funcQryGetEldersMeals())#
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that returns all elders meals from db for today.  Function: funcQryGetEldersMeals--->
    
    
    
    <!--- API that returns all guests meals from db for today.  Function: funcQryGetGuestMeals--->
	<cfif url.api eq "get_guests_meals" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#">  
            <cfcase value="GET" >
                #SerializeJSON(CreateObject("component", "cfc.queries").funcQryGetGuestMeals())#
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that returns all guests meals from db for today.  Function: funcQryGetGuestMeals--->
    
    
     
    
    <!--- API that returns Elder's Caregiver.  Function: funcQrySelectCaregivers--->
	<cfif url.api eq "get_elders_caregivers" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#"> 
            <cfcase value="GET" >
                #SerializeJSON(CreateObject("component", "cfc.queries").funcQrySelectCaregivers(url.id), 'true')#
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that returns Elder's Caregiver.  Function: funcQrySelectCaregivers--->
    
    
    
    
    <!--- API that returns a Caregiver.  Function: funcQrySelectCaregiver--->
	<cfif url.api eq "get_caregiver_by_id" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#"> 
            <cfcase value="GET" >
                #SerializeJSON(CreateObject("component", "cfc.queries").funcQrySelectCaregiver(url.id), 'true')#
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that returns a Caregiver.  Function: funcQrySelectCaregiver--->
    

    
    
<!---                                                                                                                --->    
    
    
    
    <!--- API that INSERTS service plan for an elder.  Function: funcQryInsertServicePlan --->
	<cfif url.api eq "add_service_plan" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#">
            <cfcase value="POST" >
            	<cfset plan = CreateObject("component", "cfc.queries").funcQryInsertServicePlan(FORM) />
<!---             	#CreateObject("component", "cfc.queries").funcQryUpdateProviderID(FORM.ElderID, FORM.ProviderID)#
                #CreateObject("component", "cfc.queries").funcQryUpdatePriorityID(FORM.ElderID, FORM.PriorityID)# --->
                <cflocation url="serviceplan.cfm?ElderID=#plan#"  addtoken="no"/>     
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that INSERTS service plan for an elder.  Function: funcQryInsertServicePlan --->
    
    
    
    <!--- API that INSERTS Prior Auth for an elder.  Function: funcQryInsertPriorAuth --->
	<cfif url.api eq "add_prior_auth" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#">
            <cfcase value="POST" >
            	#CreateObject("component", "cfc.queries").funcQryInsertPriorAuth(FORM)#
                <cflocation url="priorauth.cfm?ElderID=#SESSION.ElderID#"  addtoken="no"/>     
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that INSERTS Prior Auth for an elder.  Function: funcQryInsertPriorAuth --->
    
    
    
    
    <!--- API that INSERTS elders to CongregateMeals table.  Function: funcQryInsertElderMeals--->
	<cfif url.api eq "add_elder_to_mealslist" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#">
            <cfcase value="POST" >
            	#CreateObject("component", "cfc.queries").funcQryInsertElderMeals(FORM)#       
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that INSERTS elders to CongregateMeals table. Function: funcQryInsertElderMeals--->
    
    
    
    
    <!--- API that INSERTS guests to guestmeals table.  Function: funcQryInsertGuestMeals--->
	<cfif url.api eq "add_guest_to_mealslist" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#"> 
            <cfcase value="POST" >
            	#CreateObject("component", "cfc.queries").funcQryInsertGuestMeals(FORM)#
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that INSERTS guests to guestmeals table. Function: funcQryInsertGuestMeals--->
    
    
    
    
    <!--- API that INSERTS provider into database.  Function: funcQryInsertProvider--->
	<cfif url.api eq "add_provider" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#">
            <cfcase value="POST" >
            	#CreateObject("component", "cfc.queries").funcQryInsertProvider(FORM)#
            	
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that INSERTS provider into database.  Function: funcQryInsertProvider--->

  
     
    <!--- API that INSERTS OR UPDATES intake for elder.  Function: funcQryInsertIntake--->
	<cfif url.api eq "add_intake" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#">
            <cfcase value="POST" >
                	<cfset elder = CreateObject("component", "cfc.queries").funcQryInsertIntake(FORM) />
                    <cflocation url="intake.cfm?ElderID=#elder#" addtoken="no"/>
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that INSERTS intake for elder.  Function: funcQryInsertIntake---> 
    
    
    
    
    <!--- API that INSERTS Elder's Caregivers.  If elder already has caregivers in db, 
		the function will do a update instead of a insert.               Function: funcQryInsertCareGiver--->
	<cfif url.api eq "add_caregivers" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#"> 
            <cfcase value="POST" >
                <cfset variables.ID = CreateObject("component", "cfc.queries").funcQryInsertCareGiver(FORM) />
                #SerializeJSON(CreateObject("component", "cfc.queries").funcQrySelectCaregiver(variables.ID), 'true')#                
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that INSERTS Elder's Caregivers.                          Function: funcQryInsertCareGiver--->  
    
    
    
    <!--- API that INSERTS Daily Progress Note.  Function: funcQryInsertProgressNote--->
	<cfif url.api eq "add_progress_note" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#">
            <cfcase value="POST" >
            	<cfset elder = CreateObject("component", "cfc.queries").funcQryInsertProgressNote(FORM)/>
                <cflocation url="dailyprogressnote.cfm?ElderID=#elder#"  addtoken="no"/>  
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that INSERTS Daily Progress Note.  Function: funcQryInsertProgressNote--->
    
     
     
     
<!---                                                                                                   --->  

    
    
    <!--- API that UPDATES Elder's Caregivers.  If elder already has caregivers in db, 
		the function will do a update instead of a insert.               Function: funcQryUpdateElderCaregiver--->
	<cfif url.api eq "edit_caregiver" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#"> 
            <cfcase value="POST" >
                #CreateObject("component", "cfc.queries").funcQryUpdateElderCaregiver(FORM)#
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that UPDATES Elder's Caregivers.  If elder already has caregivers in db, 
		the function will do a update instead of a insert.               Function: funcQryUpdateElderCaregiver--->
    
    
    
    <!--- API that UPDATES provider in database.  Function: funcQryUpdateProvider--->
	<cfif url.api eq "edit_provider" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#">
            <cfcase value="POST" >
            	<cfif FORM.db_type eq 'update'>
                	#CreateObject("component", "cfc.queries").funcQryUpdateProvider(FORM)# 
                <cfelseif FORM.db_type eq 'delete'>
                	#CreateObject("component", "cfc.queries").funcQryUpdateProvider(FORM, 1)# 
                </cfif>            	      
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that UPDATES provider in database.  Function: funcQryUpdateProvider--->
    
    
    
    <!--- API that UPDATES prior autbh in database.  Function: funcQryUpdatePriorAuth--->
	<cfif url.api eq "edit_prior_auth" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#">
            <cfcase value="POST" >
                #CreateObject("component", "cfc.queries").funcQryUpdatePriorAuth(FORM)#   
                <cflocation url="#CGI.HTTP_REFERER#" addtoken="no" />  	      
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that UPDATES prior autbh in database.  Function: funcQryUpdatePriorAuth--->
    
    
    
    <!--- API that UPDATES provider in database.  Function: funcQryUpdateIntake--->
	<cfif url.api eq "edit_intake" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#">
            <cfcase value="POST" >
            	#CreateObject("component", "cfc.queries").funcQryUpdateIntake(url.id, FORM)#
                #CreateObject("component", "cfc.queries").funcQryUpdateElderListSignatures(url.id, FORM)#
                #CreateObject("component", "cfc.queries").funcQryUpdateInformalSupport(FORM)#
                <cflocation url="intake.cfm?ElderID=#url.id#" addtoken="no" />
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that UPDATES provider in database.  Function: funcQryUpdateIntake--->
    
    
     
     
    <!--- API that UPDATES service plan for an elder.  Function: funcQryUpdateServicePlan --->
	<cfif url.api eq "edit_service_plan" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#">
            <cfcase value="POST" >
            	#CreateObject("component", "cfc.queries").funcQryUpdateServicePlan(FORM)#
                #CreateObject("component", "cfc.queries").funcQryUpdateServicePlanSignatures(FORM.PlanId, FORM)#
<!---             	#CreateObject("component", "cfc.queries").funcQryUpdateProviderID(FORM.ElderID, FORM.ProviderID)#
            	#CreateObject("component", "cfc.queries").funcQryUpdatePriorityID(FORM.ElderID, FORM.PriorityID)# --->
                <cflocation url="#CGI.HTTP_REFERER#" addtoken="no" />
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that UPDATES service plan for an elder.  Function: funcQryUpdateServicePlan --->
    
    
    
    <!--- API that UPDATES Daily Progress Note for an elder.  Function: funcQryUpdateServicePlan --->
	<cfif url.api eq "edit_daily_progress_note" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#">
            <cfcase value="POST" ><cfdump var="#FORM#" />
            	#CreateObject("component", "cfc.queries").funcQryUpdateProgressNoteByID(FORM.DailyProgressNoteID, FORM)#
<!---                 #CreateObject("component", "cfc.queries").funcQryUpdateProviderID(FORM.ElderID, FORM.ProviderID)#
                #CreateObject("component", "cfc.queries").funcQryUpdatePriorityID(FORM.ElderID, FORM.PriorityID)# --->
                <cflocation url="#CGI.HTTP_REFERER#" addtoken="no" />
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that UPDATES service plan for an elder.  Function: funcQryUpdateServicePlan --->
    



<!---                                                                                                                --->  


        
        
    <!--- API that DELETE's an elder from todays meallist.  Function: funcQryDeleteEldersMeals--->
	<cfif url.api eq "delete_elder_from_meallist" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#"> 
            <cfcase value="POST" >
            	#CreateObject("component", "cfc.queries").funcQryDeleteEldersMeals(FORM.id)#       
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that DELETE's an elder from todays meallist.  Function: funcQryDeleteEldersMeals--->
    
    
    
    <!--- API that DELETE a Prior Auth.  Function: funcQryDeletePriorAuth--->
	<cfif url.api eq "delete_prior_auth" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#"> 
            <cfcase value="POST" >
            	#CreateObject("component", "cfc.queries").funcQryDeletePriorAuth(url.id)# 
                <cflocation url="priorauth.cfm?ElderID=#SESSION.ElderID#"  addtoken="no" />  
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that DELETE a Prior Auth.  Function: funcQryDeletePriorAuth--->
    
    
    
    
    <!--- API that DELETE's a guest from todays meallist.  Function: funcQryDeleteGuestMeals--->
	<cfif url.api eq "delete_guest_from_meallist" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#"> 
            <cfcase value="POST" >
            	#CreateObject("component", "cfc.queries").funcQryDeleteGuestMeals(FORM.id)#  
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that DELETE's a guest from todays meallist.  Function: funcQryDeleteGuestMeals--->
    
    
    
    
    <!--- API that DELETE's service plan for an elder.  Function: funcQryDeleteServicePlan --->
	<cfif url.api eq "delete_service_plan" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#">
            <cfcase value="POST" >
            	#CreateObject("component", "cfc.queries").funcQryDeleteServicePlan(url.id)#     
                <cflocation url="serviceplan.cfm?ElderID=#SESSION.ElderID#"  addtoken="no" />      
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that DELETE's service plan for an elder.  Function: funcQryDeleteServicePlan --->
    
    
    
  
    <!--- API that DELETE Daily Progress Note.  Function: funcQryDeleteProgressNote --->
	<cfif url.api eq "delete_progress_note_by_id" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#">
            <cfcase value="POST" >
            	#CreateObject("component", "cfc.queries").funcQryDeleteProgressNote(url.id)# 
                <cflocation url="dailyprogressnote.cfm?ElderID=#SESSION.ElderID#"  addtoken="no" />      
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that DELETE Daily Progress Note.  Function: funcQryDeleteProgressNote --->
    
    
    
    <!--- API that DELETE Intake.  Function: funcQryDeleteIntake --->
	<cfif url.api eq "delete_intake_by_id" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#">
            <cfcase value="POST" >
            	#CreateObject("component", "cfc.queries").funcQryDeleteIntake(url.id)#   
                <cflocation url="intake.cfm?ElderID=-1"  addtoken="no" />    
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that DELETE Intake.  Function: funcQryDeleteIntake --->
    
    
    
    <!--- API that DELETE Caregiver.  Function: funcQryDeleteIntake --->
	<cfif url.api eq "delete_caregiver_by_id" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#">
            <cfcase value="POST" >
            	#CreateObject("component", "cfc.queries").funcQryDeleteCaregiver(url.id)#   
                <cflocation url="intake.cfm?ElderID=#SESSION.ElderID#"  addtoken="no" />    
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that DELETE Intake.  Function: funcQryDeleteIntake --->
    
    
    
    <!--- API that DELETE Provider.  Function: funcQryDeleteProvider --->
	<cfif url.api eq "delete_provider" >    
        <cfswitch expression="#CGI.REQUEST_METHOD#">
            <cfcase value="POST" >
            	#CreateObject("component", "cfc.queries").funcQryDeleteProvider(FORM.id)#   
                <cflocation url="provider.cfm"  addtoken="no" />    
            </cfcase>    
        </cfswitch>
    </cfif>
	<!--- API that DELETE Provider.  Function: funcQryDeleteIntake --->
    

</cfoutput>